package pers.archives.common.utils;

import org.springframework.security.core.context.SecurityContextHolder;
import pers.archives.common.entity.SecurityUser;
import pers.archives.common.entity.User;
import pers.archives.common.ov.OVUser;

/* 用户工具类
 *@program:archives-parent
 *@author: 赵浩浩
 *@Time: 2020/9/17  17:56
 */
public class UserUtil {



    /**
     * 获取当前登录用户
     * @return
     */
    public static User getUser() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(principal == null) {
            return null;
        }
        return ((SecurityUser) principal).getCurrentUserInfo();
    }
}
